﻿namespace DoNet.ApiHttpClient.Certificate
{
    /// <summary>
    /// 证书选择策略实现‌ 基于请求头的证书选择逻辑‌
    /// </summary>
    public class HeaderBasedCertSelector : ICertSelector
    {
        /// <summary>
        /// 不使用证书时返回空
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public string SelectCertForRequest(HttpRequestMessage request)
        {
            return request.Headers.TryGetValues("X-Cert-ID", out var values) ? values.First() : "";
        }
    }
}
